<?php
// +----------------------------------------------------------------------
// | YUEGONGBAO [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.yuegongbaofund.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <yuegongbaofund@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\service\PostService;
use think\Validate;
use dragon\JoinModel;

class JoinController extends HomeBaseController
{
    public function apply()
    {
		if(!$this->request->isPost()) return $this->fetch("/apply");
		
		$validate = new Validate([
			'name' => 'require',
			'sex' => 'require',
			'mobile' => 'require',
			'company' => 'require',
			'level' => 'require',
			'province' => 'require',
			'city' => 'require',
		]);
		$validate->message([
			'name.require'    => '请填写 姓名',
			'sex.require'    => '请填写 性别',
			'mobile.require'    => '请填写 手机号码',
			'company.require'    => '请填写 公司名称',
			'level.require'    => '请填写 加盟级别',
			'province.require'    => '请填写 省份',
			'city.require'    => '请填写 城市',
			'address.require'    => '请填写 地址',
		]);
		
		$data = $this->request->post();
		if (!$validate->check($data)) {
			$this->error($validate->getError());
		}
		
		(new JoinModel())->insert($data);
		
		$this->success('提交成功');
    }

}
